package controllers

import (
	"github.com/astaxie/beego"
	"fmt"
"wcy-xmt-api/models"
)

// 用户
type UserController struct {
	beego.Controller
}

// @Title login
// @Description 登陆
// @Param app form int true "当前App编号"
// @Param account form int true "用户名"
// @Param password form int true "密码64位小写md5值"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.LoginResponse
// @router /login [post]
func (this *UserController) Login() {
	fmt.Println("run UserController Login")

	resStatus := &models.ResStatus{}
	loginResponse := &models.LoginResponse{}
	loginResponse.Code = 0
	loginResponse.Message = "成功"
	loginResponse.Uid = 232
	loginResponse.NickName = "路飞"
	loginResponse.PhoneNum = 11328747328
	loginResponse.Portrait = "http://picture.youth.cn/dmzb/201305/W020130514542662922703.jpg"
	loginResponse.Token = "237ushda8723"

	resStatus.Code = 200
	resStatus.Data = loginResponse
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title reporter login
// @Description 记者登陆
// @Param app form int true "当前App编号"
// @Param account form int true "用户名"
// @Param password form int true "密码64位小写md5值"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.LoginResponse
// @router /reporter/login [post]
func (this *UserController) ReporterLogin() {
	fmt.Println("run UserController ReporterLogin")

	resStatus := &models.ResStatus{}
	loginResponse := &models.LoginResponse{}
	loginResponse.Code = 0
	loginResponse.Message = "成功"
	loginResponse.Uid = 232
	loginResponse.NickName = "路飞"
	loginResponse.PhoneNum = 11328747328
	loginResponse.Portrait = "http://picture.youth.cn/dmzb/201305/W020130514542662922703.jpg"
	loginResponse.Token = "237ushda8723"

	resStatus.Code = 200
	resStatus.Data = loginResponse
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title register
// @Description 注册
// @Param app form int true "当前App编号"
// @Param mobile_phone_number form int true "手机号码"
// @Param password form int true "密码64位小写md5值"
// @Param nickName form int false "昵称"
// @Param portrait form int false "用户头像"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.RegisterResponse
// @router /register [post]
func (this *UserController) Register() {
	fmt.Println("run UserController Register")
	resStatus := &models.ResStatus{}
	startStatus := &models.RegisterResponse{}
	startStatus.Code = 0
	startStatus.Message = "成功"

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title change password
// @Description 修改密码
// @Param app form int true "当前App编号"
// @Param mobile_phone_number form int true "手机号码"
// @Param new_password form int true "新密码64位小写md5值"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.ChangeResponse
// @router /change [post]
func (this *UserController) ChangePassword() {
	fmt.Println("run UserController ChangePassword")
	resStatus := &models.ResStatus{}
	startStatus := &models.ChangeResponse{}
	startStatus.Code = 0
	startStatus.Message = "成功"

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title SendSms
// @Description 发送短信
// @Param mobile_phone_number form int true "手机号码"
// @Param option form int true "1为注册,2为重置密码"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.ChangeResponse
// @router /send [post]
func (this *UserController) SendSms() {
	fmt.Println("run UserController SendSms")
	resStatus := &models.ResStatus{}
	startStatus := &models.ChangeResponse{}
	startStatus.Code = 0
	startStatus.Message = "成功"

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title CheckSmsCode
// @Description 发送短信
// @Param mobile_phone_number form int true "手机号码"
// @Param sms_code form int true "手机短信验证码"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.ChangeResponse
// @router /check [post]
func (this *UserController) CheckSmsCode() {
	fmt.Println("run UserController CheckSmsCode")
	resStatus := &models.ResStatus{}
	startStatus := &models.ChangeResponse{}
	startStatus.Code = 0
	startStatus.Message = "成功"

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title UploadPortrait
// @Description 发送短信
// @Param uid form int true "用户id"
// @Param portrait form string true "图片的base64编码"
// @Param token form int true "登陆成功返回的token"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.UploadPortraitResponse
// @router /upload [post]
func (this *UserController) UploadPortrait() {
	fmt.Println("run UserController UploadPortrait")
	resStatus := &models.ResStatus{}
	startStatus := &models.UploadPortraitResponse{}
	startStatus.Code = 0
	startStatus.PortraitUrl = "http://imgsrc.baidu.com/forum/pic/item/d833c895d143ad4b83a2e96282025aafa50f0687.jpg"
	startStatus.Message = "成功"

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}